import http from "../http";
import { reactive } from "vue";

const cates = reactive({
    cates_list: [], // 头部导航列表
    cc_list: {},
    course_list: [],
    c_list: [],
    cates_l: [],

    get_cate_nav() {
        // 获取头部导航菜单
        return http.get("home/category/").then(response => {
            this.cates_list = response.data.data;

        })
    },

    get_course(cateid) {
        // 获取头部导航菜单
        return http.get("home/cate/?did="+cateid).then(response => {
            console.log('课程列表数据请求成功.....');
            console.log(response);
            this.course_list = response.data.cousers
        })
    },

    get_course_list(catesid, ind) {
        // 获取轮播广告列表
        return http.get(`home/course/${catesid}/`).then(response => {
            console.log('课程列表数据请求成功.....');
            console.log(response);
            this.cate_info = response.data.data;
          })
        return http.get("home/course/?did=" + catesid).then(response => {
            if (catesid) {
                this.c_list[ind]['courses'] = response.data.clist
            } else {
                this.c_list = response.data.clist;
            }

        })
    }
})

export default cates;